import Mock from '../mockjs/dist/mock-min.js';
import system from './data/system.js';
import cart from './data/cart.js';
import category from './data/category.js';
import product from './data/product.js';
import gift from './data/gift.js';
import order from './data/order.js';
import giftOrder from './data/giftOrder.js';
import ad from './data/ad.js';
import address from './data/address.js';
import client from './data/client.js';

let baseURL = "http://localhost:8010/wx";

let businessDataArray = [
	system,category,product,
	order,cart,gift,
	giftOrder,ad,address,client
];

for (let index in businessDataArray) {
	let itemDataArray = businessDataArray[index];
	for (let jndex in itemDataArray) {
		let dataObject = itemDataArray[jndex];
		let url = baseURL+dataObject.key;
		
		Mock.mock(RegExp(url + ".*"), dataObject.method, () => {
			if ("function" === typeof dataObject.data) {
				return dataObject.data();
			}
			return dataObject.data;
		});
	}
}